package com.qsbg.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qsbg.entity.Dynamic;
import com.qsbg.entity.vo.DynamicUserActivityVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface DynamicMapper extends BaseMapper<Dynamic> {
    @Select({"select t.*, t1.profile_id, t1.real_name, t2.activity_name " +
            "FROM sys_dynamic t " +
            "LEFT JOIN sys_user t1 ON t1.user_id = t.user_id " +
            "LEFT JOIN sys_activity t2 ON t2.activity_id = t.activity_id " +
            "${ew.customSqlSegment}"})
    IPage<DynamicUserActivityVo> getDynamicList(@Param("page") Page<DynamicUserActivityVo> page, @Param(Constants.WRAPPER) Wrapper<DynamicUserActivityVo> wrapper);


    @Select({"select t.*, t1.profile_id, t1.real_name, t2.activity_name " +
            "FROM sys_dynamic t " +
            "LEFT JOIN sys_user t1 ON t1.user_id = t.user_id " +
            "LEFT JOIN sys_activity t2 ON t2.activity_id = t.activity_id " +
            "where t.id = #{id}"})
    DynamicUserActivityVo getDynamic(@Param("id") Integer id);
}
